package com.guli.gulimall.third;

import com.aliyun.oss.OSS;
import com.aliyun.oss.model.GetObjectRequest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.validation.Valid;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * @projectName: gulimall-1911a-lxd
 * @package: com.guli.gulimall.third
 * @className: ThirdDemo
 * @author: XDF
 * @description: TODO
 * @date: 2022/5/26 19:06
 * @version: 1.0
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class ThirdDemo {


    @Autowired
    private OSS oss;

    @Value("${alibaba.cloud.access-key}")
    private String accessKey;
    @Value("${alibaba.cloud.secret-key}")
    private String secretKey;
    @Value("${alibaba.cloud.oss.endpoint}")
    private String endpoint;
    @Value("${alibaba.cloud.oss.bucket-name}")
    private String bucketName;

    @Test
    public void ossTest(){
        try {
            oss.putObject(bucketName,"456.jpg",new FileInputStream("D:\\壁纸\\QQ图片20210318184055.jpg"));
            System.out.println("Sring-Boot的上传图片");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }
}
